package nero.yncc.com.createart.fragment;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import nero.yncc.com.createart.R;
import nero.yncc.com.createart.activity.ActivityWeb;
import nero.yncc.com.createart.bean.BeanAd;
import nero.yncc.com.createart.utils.ImageUtils;

/**
 * Created by Brainstorm on 2017/a3/19.
 */

public class FragmentAdIndex extends Fragment {

    BeanAd beanAd;

    TextView tv_ad;
    ImageView iv_ad;
    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view=inflater.inflate(R.layout.fragment_ad_index,container,false);
        try {
            beanAd=(BeanAd) getArguments().getSerializable("ad");
//
//
//            tv_ad=(TextView) view.findViewById(R.id.tv_ad);
            iv_ad=view.findViewById(R.id.iv_ad);
            iv_ad.setImageResource(R.mipmap.banner);
            ImageUtils.BindImage(getContext(),iv_ad,beanAd.getAd_code(),4);

            iv_ad.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    //跳转浏览器
                    Intent intent=new Intent(getContext(), ActivityWeb.class);
                    intent.putExtra("url",beanAd.getAd_link());
                    intent.putExtra("title","资讯");
                    startActivity(intent);
                }
            });

        }catch (Exception e){

        }

        return view;
    }


}